home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsdk.lha / include / db.h < prev    next >
C/C++ Source or Header  |  1996-03-13  |  5KB  |  158 lines

  1. /*-
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)db.h    5.10 (Berkeley) 4/2/91
  34.  */
  35.  
  36. #ifndef _DB_H_
  37. #define    _DB_H_
  38.  
  39. #include <sys/cdefs.h>
  40.  
  41. /* flags for DB.put() call */
  42. #define    R_IBEFORE    1        /* RECNO */
  43. #define    R_IAFTER    2        /* RECNO */
  44. #define    R_NOOVERWRITE    3        /* BTREE, HASH, RECNO */
  45. #define    R_PUT        4        /* BTREE, HASH, RECNO */
  46.  
  47. /* flags for DB.seq() call */
  48. #define    R_CURSOR    1        /* BTREE, RECNO */
  49. #define    R_FIRST        2        /* BTREE, HASH, RECNO */
  50. #define    R_LAST        3        /* BTREE, RECNO */
  51. #define    R_NEXT        4        /* BTREE, HASH, RECNO */
  52. #define    R_PREV        5        /* BTREE, RECNO */
  53.  
  54. /* key/data structure -- a data-base thang */
  55. typedef struct {
  56.     void *data;
  57.     int size;
  58. } DBT;
  59.  
  60. /* access method description structure */
  61. typedef struct __db {
  62.     void *internal;        /* access method private */
  63. #define    DB_BTREE    1
  64. #define    DB_HASH        2
  65. #define    DB_RECNO    3
  66.     int type;        /* type of underlying db */
  67.     int (*close)();
  68.     int (*del)();
  69.     int (*get)();
  70.     int (*put)();
  71.     int (*seq)();
  72.     int (*sync)();
  73. } DB;
  74.  
  75. #define    BTREEMAGIC    0x053162
  76. #define    BTREEVERSION    2
  77.  
  78. /* structure used to pass parameters to the btree routines */
  79. typedef struct {
  80. #define    R_DUP        0x01    /* duplicate keys */
  81.     u_long flags;
  82.     int cachesize;        /* bytes to cache */
  83.     int psize;        /* page size */
  84.     int (*compare)();    /* compare function */
  85.     int lorder;        /* byte order */
  86. } BTREEINFO;
  87.  
  88. #define    HASHMAGIC    0x061561
  89. #define    HASHVERSION    1
  90.  
  91. /* structure used to pass parameters to the hashing routines */
  92. typedef struct {
  93.     int bsize;        /* bucket size */
  94.     int ffactor;        /* fill factor */
  95.     int nelem;        /* number of elements */
  96.     int cachesize;        /* bytes to cache */
  97.     int (*hash)();        /* hash function */
  98.     int lorder;        /* byte order */
  99. } HASHINFO;
  100.  
  101. /* structure used to pass parameters to the record routines */
  102. typedef struct {
  103. #define    R_FIXEDLEN    0x01    /* fixed-length records */
  104.     u_long flags;
  105.     int cachesize;        /* bytes to cache */
  106.     size_t reclen;        /* record length (fixed-length records) */
  107.     u_char bval;        /* delimiting byte (variable-length records */
  108. } RECNOINFO;
  109.  
  110. /* key structure for the record routines */
  111. typedef struct {
  112.     u_long number;
  113.     u_long offset;
  114.     u_long length;
  115. #define    R_LENGTH    0x01    /* length is valid */
  116. #define    R_NUMBER    0x02    /* record number is valid */
  117. #define    R_OFFSET    0x04    /* offset is valid */
  118.     u_char valid;
  119. } RECNOKEY;
  120.  
  121. /* Little endian <--> big endian long swap macros. */
  122. #define BLSWAP(a) { \
  123.     u_long _tmp = a; \
  124.     ((char *)&a)[0] = ((char *)&_tmp)[3]; \
  125.     ((char *)&a)[1] = ((char *)&_tmp)[2]; \
  126.     ((char *)&a)[2] = ((char *)&_tmp)[1]; \
  127.     ((char *)&a)[3] = ((char *)&_tmp)[0]; \
  128. }
  129. #define    BLSWAP_COPY(a,b) { \
  130.     ((char *)&(b))[0] = ((char *)&(a))[3]; \
  131.     ((char *)&(b))[1] = ((char *)&(a))[2]; \
  132.     ((char *)&(b))[2] = ((char *)&(a))[1]; \
  133.     ((char *)&(b))[3] = ((char *)&(a))[0]; \
  134. }
  135.  
  136.  
  137. /* Little endian <--> big endian short swap macros. */
  138. #define BSSWAP(a) { \
  139.     u_short _tmp = a; \
  140.     ((char *)&a)[0] = ((char *)&_tmp)[1]; \
  141.     ((char *)&a)[1] = ((char *)&_tmp)[0]; \
  142. }
  143. #define BSSWAP_COPY(a,b) { \
  144.     ((char *)&(b))[0] = ((char *)&(a))[1]; \
  145.     ((char *)&(b))[1] = ((char *)&(a))[0]; \
  146. }
  147.  
  148. __BEGIN_DECLS
  149. DB    *btree_open
  150.         __P((const char *, int, int, const BTREEINFO *));
  151. DB    *hash_open
  152.         __P((const char *, int, int, const HASHINFO *));
  153. DB    *recno_open
  154.         __P((const char *, int, int, const RECNOINFO *));
  155. __END_DECLS
  156.  
  157. #endif /* !_DB_H_ */
  158.